﻿#pragma once

#include"common.h"

//单例模式--饿汉⽅式
class Centralcache
{
public:
	static Centralcache* GetInst()
	{
		return &_sInst;
	}

	// 获取一个非空的span
	Span* GetOneSpan(SpanList& list, size_t byte_size);

	// 从中心缓存获取一定数量的对象给thread cache
	size_t FetchRangeObj(void*& start, void*& end, size_t batchNum, size_t size);

	// 将一定数量的对象释放到span跨度
	void ReleaseListToSpans(void* start, size_t byte_size);

private:
	SpanList _SpanList[NFREELIST];//_SpanList里有NFREELIST个桶
private:
	Centralcache(){}//不允许外面用构造和拷贝
	Centralcache(const Centralcache&) = delete;
	static  Centralcache _sInst;
};
